jQuery.fn.equalHeight = function () {
    var tallest = 0;
    return this.each(function () {
        var thisHeight = jQuery(this).height();
        if (thisHeight > tallest) {
            tallest = thisHeight;
        }
    }).height(tallest);
};
(function (jQuery) {
    var readyStarted = false;
    var readyEnded = false;
    jQuery(function () {
        readyStarted = true;
    });
    jQuery(document).bind("ready", function () {
        readyEnded = true;
    });
    jQuery.rawContentHandler = function (cb) {
        if (jQuery.isFunction(cb)) {
            if (!readyStarted) {
                jQuery(function () {
                    jQuery.rawContentHandler(cb);
                });
            } else {
                if (!readyEnded) {
                    var tgt = jQuery("body")[0];
                    cb.call(tgt, tgt.childNodes);
                }
                jQuery(window).bind("rawContent", function (e, items) {
                    cb.call(e.target, items || e.target.childNodes);
                });
            }
        }
    };
})(jQuery);

jQuery.WPV = jQuery.WPV || {};
var MEDIA = {layout: {}};
(function($) {
    function fixMetas(firstTime) {
        $('meta[name="viewport"]').each(function(i, el) {
            el.content = firstTime ? 'width=device-width,minimum-scale=1.0,maximum-scale=1.0' : 'width=device-width,minimum-scale=0.25,maximum-scale=1.6';
        });
    }
    fixMetas(true);
    $("body").bind('gesturestart', fixMetas);
})(jQuery);
jQuery.mediaWidth = function() {
    if (this.browser.mozilla || window.opera || (this.browser.msie && parseInt(this.browser.version, 10) >= 9)) {
        return window.innerWidth;
    }
    return document.body.clientWidth || document.documentElement.clientWidth;
};
(function($, undefined) {
    var IE = $.browser.msie;
    var IE8 = IE && $.browser.version == 8;
    var J_WIN = $(window);
    var J_HTML = $("html");
    var WIN_WIDTH = $.mediaWidth();
    var IS_TOUCH = 'ontouchstart' in document.documentElement;
    var MIN_GRID_WIDTH = 700;
    $.fn.aPosition = function() {
        thisLeft = this.offset().left;
        thisTop = this.offset().top;
        thisParent = this.parent();
        parentLeft = thisParent.offset().left;
        parentTop = thisParent.offset().top;
        return {left: thisLeft - parentLeft,top: thisTop - parentTop};
    };
    var LAYOUT_SIZES = [{min: 0,max: 479,className: "layout-smallest"}, {min: 480,max: 699,className: "layout-small"}, {min: 700,max: 959,className: "layout-medium"}, {min: 960,max: Infinity,className: "layout-max"}, {min: 0,max: 699,className: "layout-below-medium"}, {min: 0,max: 959,className: "layout-below-max"}];
    var lastClass, sizesLength = LAYOUT_SIZES.length, i;
    J_WIN.bind('resize.sizeClass load.sizeClass', function() {
        WIN_WIDTH = $.mediaWidth();
        var toAdd = [], toDel = [];
        map = {};
        for (i = 0; i < sizesLength; i++) {
            if (WIN_WIDTH >= LAYOUT_SIZES[i].min && WIN_WIDTH <= LAYOUT_SIZES[i].max) {
                toAdd.push(LAYOUT_SIZES[i].className);
                map[LAYOUT_SIZES[i].className] = true;
            } 
            else {
                toDel.push(LAYOUT_SIZES[i].className);
                map[LAYOUT_SIZES[i].className] = false;
            }
        }
        MEDIA.layout = map;
        toAdd = toAdd.join(" ");
        toDel = toDel.join(" ");
        if (lastClass != toAdd) {
            lastClass = toAdd;
            J_HTML.removeClass(toDel).addClass(toAdd);
            J_WIN.trigger("switchlayout");
        }
    });
    var delayedResizeTimeout;
    function delayedResizeHandler() {
        if (delayedResizeTimeout) {
            window.clearTimeout(delayedResizeTimeout);
        }
        delayedResizeTimeout = setTimeout(function() {
            J_WIN.trigger("delayedResize");
        }, 150);
    }
    J_WIN.bind('resize', delayedResizeHandler);
    function invokeIfPageContains(selector, f) {
        if ($(selector).length) {
            f();
        }
    }
    $(function() {
        J_WIN.triggerHandler('resize.sizeClass');
        function toggleSliderRunning() {
            $("#header-slider").vamtamSlider($("body").is(".show-menu") ? "pause" : "resume");
        }
        $('#show-menu-toggle').bind($.WPV.Constants.Events.touchstart, function(e) {
            var menus = $('#menus').unsetTransition();
            if ($('body').is('.show-menu')) {
                $('body').removeClass('show-menu');
                $("#header-slider").vamtamSlider("pause");
                menus.css("height", menus.height()).setTransition({height: 0}, 500, "swing", 0, function() {
                    $("#header-slider").vamtamSlider("resume");
                });
            } 
            else {
                $('body').addClass('show-menu');
                //$("#header-slider").vamtamSlider("pause");
                menus.setTransition({height: menus[0].scrollHeight}, 500, "swing", 0, function() {
                    menus.css("height", "auto");
                });

            }
            e.stopPropagation();
        });
        $('body').bind($.WPV.Constants.Events.touchstart, function(e) {
            if (MEDIA.layout["layout-below-max"] && $('body').is('.show-menu')) {
                var menus = $('#menus').unsetTransition();
                $('body').removeClass('show-menu');
                menus.css("height", menus.height()).setTransition({height: 0}, 500, "swing", 0, function() {
                    $("#header-slider").vamtamSlider("resume");
                });
                return false;
            }
        });
        $('#menus').bind($.WPV.Constants.Events.touchstart, function(e) {
            e.stopPropagation();
        });
        J_WIN.bind("switchlayout", function() {
            if (MEDIA.layout["layout-max"]) {
                $('body').removeClass('show-menu');
                $('#menus').unsetTransition().css({height: "auto",height:(jQuery('#menus').parent().height()),overflow: "visible"});
                jQuery('.header-right').show();
                jQuery('.loginmobile').hide();
            } 
            else {
                if (!$('body').is('.show-menu')) {
                    $('#menus').css({overflow: "hidden",height: 0});
                    jQuery('.header-right').hide();
                    jQuery('.loginmobile').show();
                }
            }
        });

        $(".menu-item > .sub-menu").each(function() {
            $(this).parent().addClass("has-submenu");
        });
        $("#main-menu-main a").bind("click", function(e) {
            e.stopPropagation();
            if ($(this).parent().is('.has-submenu') && $(window).width() - e.pageX < 80) {
                function hideOthers(callback) {
                    var toHide = $(e.target).parent().siblings().find('.sub-menu');
                    if (toHide.length) {
                        var hidden = 0;
                        toHide.each(function() {
                            var h = $(this).height();
                            if (h) {
                                $(this).css("height", h).setTransition({"height": 0}, 600, "swing", 0, function() {
                                    if (++hidden >= toHide.length) {
                                        callback();
                                    }
                                });
                            } else {
                                hidden++;
                            }
                        });
                        if (hidden >= toHide.length) {
                            callback();
                        }
                    } 
                    else {
                        callback();
                    }
                }
                hideOthers(function() {
                    var sub = $(e.target).next('.sub-menu');
                    if (sub) {
                        var h = sub.height();
                        if (h) {
                            sub.css("height", h).setTransition({"height": 0}, 600, "swing");
                        } 
                        else {
                            sub.css("height", h).setTransition({"height": sub[0].scrollHeight}, 600, "swing", 0, function() {
                                sub.css("height", "auto");
                            });
                        }
                    }
                });
                return false;
            }
        });
        if ($('html').is('.placeholder')) {
            $.rawContentHandler(function() {
                $('.label-to-placeholder label[for]').each(function() {
                    $('#' + $(this).prop('for')).attr('placeholder', $(this).text());
                    $(this).hide();
                });
            });
        }
        (function() {
            var delay = 500, timer;
            function clearTimer() {
                if (timer)
                    clearTimeout(timer);
            }
            function setInitialState(noDelay) {
                if (noDelay) {
                    $("#menu-main-menu-main .sub-menu.visible").removeClass("visible");
                    var toActivate = $("#menu-main-menu-main").find("> .current_page_parent, > .current-menu-parent, > .current-menu-item, > .current_page_item, > .current-menu-ancestor, > .current_page_ancestor");
                    if (!toActivate.length) {
                        toActivate = $("#menu-main-menu-main > li");
                    }
                    toActivate.eq(0).find(" > .sub-menu").addClass("visible");
                } 
                else {
                    clearTimer();
                    timer = setTimeout(function() {
                        setInitialState(true);
                    }, delay);
                }
            }
            function closeSubMenus(menuItem) {
                clearTimer();
                timer = setTimeout(function() {
                    $(menuItem).find(".sub-menu.visible").removeClass("visible");
                }, delay);
            }
            $("#menu-main-menu-main .menu-item").hover(function(e) {
                if (MEDIA.layout["layout-below-max"])
                    return;
                clearTimer();
                $(this).parent().find(".sub-menu.visible").removeClass("visible");
                $("> .sub-menu", this).addClass("visible");
            }, function(e) {
                if (MEDIA.layout["layout-below-max"])
                    return;
                closeSubMenus(this);
            });
            $("#menu-main-menu-main").mouseleave(function() {
                if (MEDIA.layout["layout-below-max"])
                    return;
                setInitialState();
            });
            setInitialState(true);
        })();
        J_WIN.bind('resize.video load.video', function() {
            $('.post-video, .portfolio_image_wrapper').find('iframe, object, embed, video').each(function() {
                var v = $(this);
                v.css({height: v.prop('height') * v.width() / v.prop('width')});
            });
        });
        $("#header-slider").bind("sliderStarted.scaleSlider", function(e, slider) {
            var MIN_WIDTH = 320;
            var MAX_WIDTH = 960;
            var MIN_FONTSIZE = 15;
            var $elem = $(slider.element);
            var toScale = $elem.find(".slide-wrapper .slide.type-html .scale-font, .caption");
            toScale.each(function() {
                $(this).data("baseFontSize", parseFloat($(this).css("font-size")));
            });
            function doScale() {
                var w = $elem.width();
                if (w >= MAX_WIDTH) {
                    toScale.each(function() {
                        $(this).css("font-size", $(this).data("baseFontSize"));
                    });
                } else {
                    var q = Math.max(w, MIN_WIDTH) / MAX_WIDTH;
                    toScale.each(function() {
                        $(this).css("font-size", Math.max($(this).data("baseFontSize") * q, MIN_FONTSIZE));
                    });
                }
                fixVideo();
            }
            function fixVideo() {
                $elem.find(".video_frame iframe").each(function() {
                    var v = $(this);
                    v.css("height", Math.floor(v.prop('height') * v.width() / v.prop('width')));
                });
            }
            $(window).bind("resize.scaleSlider", doScale);
            doScale();
            $elem.bind("afterRun", fixVideo);
        });
        $('.animated.flash, .animated.wiggle').live('mouseover focus click', function() {
            $(this).removeClass('animated');
        });
        if ($.isArray(window.wpvBgSlides)) {
            var body = $('body');
            body.fastSlider({}, wpvBgSlides);
            $(window).bind('keydown', function(e) {
                switch (e.keyCode || e.which) {
                    case 37:
                        (body.data("fastSlider") && body.data("fastSlider").prev());
                        break;
                    case 38:
                        (body.data("fastSlider") && body.data("fastSlider").goToPrevGalleryItem());
                        break;
                    case 39:
                        (body.data("fastSlider") && body.data("fastSlider").next());
                        break;
                    case 40:
                        (body.data("fastSlider") && body.data("fastSlider").goToNextGalleryItem());
                        break;
                }
                ;
            });
        }
        $("#footer-sidebars > .row[data-num=1] > aside").find(".widget.wpv_contactinfo, .widget.wpv_icon_link").closest("aside").addClass("custom");
        (function() {
            var IS_OVER;
            $(window).bind("delayedResize.teammember", function(e) {
                if (IS_OVER)
                    return;
                $(".team-member.has-content .team-member-info").css({height: "auto"});
                if (MEDIA.layout["layout-below-medium"]) {
                    $(".team-member.has-content").not(".simple").find(".description").css("height", 0).end().addClass("simple");
                } 
                else {
                    $(".team-member.has-content.simple").removeClass("simple").find(".description").css("height", "auto");
                }
            });
            function isMultiColumn(member) {
                return member.outerWidth() < member.closest(".row").width() * .9;
            }
            $(".team-member.has-content").each(function() {
                $(this).closest(".row").addClass("team-member-row");
            });
            var memberRows = $(".team-member-row"), z = memberRows.length + 60;
            memberRows.each(function() {
                $(this).toggleClass("single", $(this).find(".team-member").length === 1).css("zIndex", z--);
            });
            $(".team-member.has-content").hover(function() {
                IS_OVER = 1;
                var member = $(this), desc = member.find(".description");
                var hideTimer = member.data("closeTimer");
                if (hideTimer) {
                    clearTimeout(hideTimer);
                }
                if (desc.length) {
                    if (!member.is(".simple") && isMultiColumn(member)) {
                        $(".team-member .team-member-info").css("height", "auto").equalHeight();
                        desc.css({height: "auto",top: "100%"});
                    } 
                    else {
                        desc.css("height", desc[0].scrollHeight);
                    }
                }
            }, function() {
                IS_OVER = 0;
                var member = $(this);
                if (member.is(".simple") && !isMultiColumn(member)) {
                    member.find(".description").css({height: 0});
                }
                member.data("closeTimer", setTimeout(function() {
                    member.find(".description").css({"top": -9999});
                }, 300));
            });
        })();
        var tooltip_animation = 250;

        jQuery.WPV.initHoverFX = function() {
        };
        function getPortfolioColumnCount($ul) {
            var cnt = 1;
            if ($ul.is(".portfolio_two_columns"))
                cnt = 2;
            else if ($ul.is(".portfolio_three_columns"))
                cnt = 3;
            else if ($ul.is(".portfolio_four_columns"))
                cnt = 4;
            if (MEDIA.layout["layout-smallest"])
                return 1;
            if (MEDIA.layout["layout-small"])
                return Math.min(2, cnt);
            if (MEDIA.layout["layout-medium"])
                return Math.min(3, cnt);
            return Math.min(4, cnt);
        }
        function getPortfolioColumnWidth($ul) {
            switch (getPortfolioColumnCount($ul)) {
                case 2:
                    return 0.49;
                case 3:
                    return 0.32;
                case 4:
                    return 0.235;
            }
            return 1;
        }
        function getPortfolioColumnGap($ul) {
            if (getPortfolioColumnCount($ul) === 1) {
                return 0;
            }
            return 0.02;
        }
        jQuery.WPV.initPortFolio = function(context) {
            var portfolioImages = $('.portfolios.sortable:not(.scroll-x)', context || document).find("img.lazy").not(".jail-started");
            portfolioImages.closest(".portfolios.sortable > ul").parent().addClass("loading").css("backgroundPosition", "center 150px");
            function callback() {
                setTimeout(function() {
                    var portfolios = $(".portfolios.sortable", context || document);
                    portfolios.each(function(pi) {
                        var list = $('> ul', this), items = $("> li", list).removeAttr("class"), links = $('.sort_by_cat a', this), cat = "all", toShow = items, toHide = $();
                        list.css({position: "relative",overflow: "visible",height: list.height()});
                        function updateThumbnailPositions(internal, cb) {
                            list.css("height", list.height());
                            var row = 0, col = 0, baseLineY = 0, baseLineX = 0, rowHeight = 0, colCount = getPortfolioColumnCount(list), listWidth = list.width(), colWidthF = getPortfolioColumnWidth(list), colWidth = Math.floor(listWidth * colWidthF);
                            var colGapF = getPortfolioColumnGap(list), colGap = colGapF * 100, rowGap = 0, len = toShow.length;
                            var onComplete = $.createCountingCallback(1, function() {
                                list.trigger("portfolioReflow");
                            });
                            toShow.each(function(j) {
                                var isFirst = j % colCount === 0 || 1 === colWidthF;
                                var item = $(this).css({height: "auto",width: colWidth,marginBottom: 0}).show();
                                $(".vamtam-slider", this).each(function() {
                                    var inst = $(this).data("vamtamSlider");
                                    if (inst) {
                                        $(inst.element).unsetTransition(true, true).css("height", inst._getDisplayHeight());
                                    }
                                });
                                var height = item.outerHeight() + rowGap;
                                if (isFirst) {
                                    baseLineY += rowHeight;
                                    rowHeight = 0;
                                    col = 0;
                                }
                                rowHeight = Math.max(rowHeight, height);
                                baseLineX = col * (colWidth + listWidth * colGapF);
                                col++;
                                var cssFrom = {display: "block",zIndex: 200};
                                var cssTo = {top: baseLineY,left: baseLineX,avoidTransforms: true};
                                if (!internal) {
                                    cssFrom.opacity = 0;
                                    cssTo.opacity = 1;
                                }
                                if (internal) {
                                    $(this).css(cssFrom).css(cssTo);
                                } 
                                else {
                                    list.addClass("animated");
                                    item.css(cssFrom).delay(cat == 'all' ? Math.max(0, (j - 3) * 100) : j * 200).queue(function() {
                                        item.animate(cssTo, {easing: "easeInOutQuint",duration: 800,complete: function() {
                                                item.css("zIndex", 2);
                                                if (j == toShow.length - 1) {
                                                    list.removeClass("animated");
                                                }
                                        }});
                                    }).dequeue();
                                }
                                if (j === len - 1) {
                                    baseLineY += rowHeight;
                                }
                            });
                            toHide.filter(":visible").css({zIndex: 1}).animate({opacity: "hide"}, cat == 'all' ? 1000 : 600, "swing");
                            list.clearQueue("listHeight").queue("listHeight", function() {
                                list.animate({height: baseLineY}, IS_TOUCH ? 1 : 800, "swing", function() {
                                    list.parent().addClass("loaded");
                                    list.trigger("portfolioReflow");
                                    if ($.isFunction(cb)) {
                                        cb();
                                    }
                                });
                            }).dequeue("listHeight");
                        }
                        links.click(function(e) {
                            links.removeClass('active');
                            $(this).addClass('active');
                            cat = $(this).attr('data-value');
                            toShow = cat == 'all' ? items : items.filter('[data-type*=' + cat + ']');
                            toHide = cat == 'all' ? $([]) : items.not('[data-type*=' + cat + ']');
                            toShow.stop(1, 1);
                            toHide.stop(1, 1);
                            list.trigger("portfolioSortStart", [cat]);
                            updateThumbnailPositions(false, function() {
                                list.trigger("portfolioSortComplete", [cat]);
                            });
                            return false;
                        });
                        setTimeout(function() {
                            updateThumbnailPositions(true);
                            items.css({position: "absolute",opacity: 1});
                            list.addClass("transitionable").animate({opacity: 1}, {duration: 600,queue: false}).parent().removeClass("loading").addClass("loaded");
                            J_WIN.bind({switchlayout: function(e) {
                                    updateThumbnailPositions(true);
                                },resize: function(e) {
                                    updateThumbnailPositions(true);
                            }});
                            if (pi >= portfolios.length - 1) {
                                $(window).trigger("loadPortfolio");
                            }
                            updateThumbnailPositions(true);
                        }, 1000);
                    });
                }, 0);
            }
            var timer;
            if (portfolioImages.length) {
                timer = setTimeout(callback, 5000);
                portfolioImages.addClass("jail-started").jail({speed: 1000,event: false,callback: function() {
                        if (timer) {
                            clearTimeout(timer);
                        }
                        callback();
                }});
            } 
            else {
                callback();
            }
        };
        jQuery.WPV.initPortFolio(document);
        $(window).bind('resize scroll', function() {
            $('#scroll-to-top').toggleClass("visible", window.pageYOffset > 0);
        });
        $('#scroll-to-top').click(function() {
            $('html,body').animate({scrollTop: 0}, 300);
        });
    });
    (function() {
        var fadeSpeed = 200, fadeEasing = "easeInOutQuad", sizeSpeed = 400, sizeEasing = "easeInOutQuad", delay = 200, hoverColumn, isConverted;
        $(".row:has(> div > .services.has-more)").each(function(i, o) {
            var origRow = $(o), row = origRow.clone().insertAfter(o), cols = row.find("> div").addClass("has-more-col"), len = cols.length;
            if (len < 2) {
                return;
            }
            var rowWidth, normalWidth, smallWidth, bigWidth;
            row.mouseleave(restoreAll);
            $("body").bind("touchstart", function() {
                if (hoverColumn) {
                    hoverColumn = null;
                    restoreAll();
                }
            });
            cols.bind("touchstart", function(e) {
                e.stopPropagation();
            });
            function convert() {
                cols.removeClass("one_half grid-1-2 one_third grid-1-3 one_fourth grid-1-4 one_fifth grid-1-5 one_sixth grid-1-6 two_thirds grid-2-3 two_fourths grid-2-4 two_fifths grid-2-5 two_sixths grid-2-6 three_fourths grid-3-4 three_fifths grid-3-5 three_sixths grid-3-6 four_fifths grid-4-5 four_sixths grid-4-6 five_sixths grid-5-6").css({position: "relative","float": "left"});
                if (!row.find("> .column-scroller").length) {
                    row.wrapInner('<div class="column-scroller"/>');
                }
                isConverted = 1;
            }
            function init(e) {
                var h = 0;
                if (MEDIA.layout["layout-below-medium"]) {
                    row.hide();
                    origRow.show();
                } 
                else {
                    origRow.hide();
                    row.show();
                    row.css("width", "100%");
                    if (rowWidth != row.width()) {
                        rowWidth = row.width();
                        var gap = (rowWidth / 100) * 3;
                        rowWidth = Math.floor(rowWidth - (gap * (len - 1)));
                        normalWidth = rowWidth / len;
                        smallWidth = rowWidth / (len + 1);
                        bigWidth = smallWidth * 2;
                        cols.removeData("targetHeight").width(normalWidth).css("height", "auto").each(function() {
                            h = Math.max(h, $(this).innerHeight());
                        }).height(h);
                        if (!isConverted)
                            convert();
                        cols.css("margin", "0 " + gap + "px 0 0").eq(cols.length - 1).css("marginRight", 0);
                    }
                }
            }
            J_WIN.bind("resize load", init);
            function getColumnTargetHeight(col) {
                var meta = $(col).data("targetHeight");
                if (!meta) {
                    var toShow = $(".open", col).css({visibility: "hidden",width: bigWidth,height: "auto"}).addClass("visible"), content = $(".open-content", toShow).css("opacity", 0);
                    meta = toShow.outerHeight();
                    toShow.css({width: "100%",height: 0,paddingTop: 0,paddingBottom: 0,visibility: "visible"});
                }
                return meta;
            }
            function restoreAll() {
                cols.stop(1, 0);
                var Q = $({});
                Q.queue(function() {
                    var toFadeOut = cols.find(".closed, .open-content"), l = toFadeOut.length;
                    if (!l) {
                        Q.dequeue();
                    } 
                    else {
                        var done = 0;
                        toFadeOut.each(function(i, content) {
                            $(content).stop(1, 0);
                            if (!$(content).is(":visible") || String($(content).css("opacity")) == "0") {
                                if (++done >= l) {
                                    Q.dequeue();
                                }
                            } 
                            else {
                                $(content).animate({opacity: 0}, fadeSpeed, fadeEasing, function() {
                                    if (++done >= l) {
                                        Q.dequeue();
                                    }
                                });
                            }
                        });
                    }
                });
                Q.queue(function() {
                    cols.delay(fadeSpeed).animate({width: normalWidth}, {duration: sizeSpeed,easing: sizeEasing,queue: false});
                    cols.find(".open").stop(1, 0).delay(fadeSpeed).animate({height: 0}, sizeSpeed, sizeEasing);
                    cols.find(".closed").stop(1, 0).delay(fadeSpeed).animate({opacity: 1}, fadeSpeed, fadeEasing);
                });
            }
            cols.find(".open").wrapInner('<div class="open-content"></div>');
            cols.each(function(j, item) {
                var $item = $(item);
                $item.mouseenter(function() {
                    hoverColumn = this;
                    cols.stop(1, 0);
                    var otherCols = cols.not(this);
                    $item.delay(delay)
                    $item.queue(function() {
                        var toFadeOut = $item.find(".closed").add(".open-content", cols), l = toFadeOut.length;
                        if (!l) {
                            $item.dequeue();
                        } 
                        else {
                            var done = 0;
                            toFadeOut.each(function(i, content) {
                                $(content).stop(1, 0);
                                if (String($(content).css("opacity")) == "0") {
                                    if (++done >= l) {
                                        $item.dequeue();
                                    }
                                } 
                                else {
                                    $(content).stop(1, 0).animate({opacity: 0}, fadeSpeed, fadeEasing, function() {
                                        if (++done >= l) {
                                            $item.dequeue();
                                        }
                                    });
                                }
                            });
                        }
                    });
                    $item.queue(function() {
                        otherCols.find(".open").stop(1, 0).animate({height: 0}, sizeSpeed, sizeEasing);
                        otherCols.animate({width: smallWidth}, {duration: sizeSpeed,easing: sizeEasing,queue: false});
                        $item.dequeue();
                    });
                    $item.queue(function(next) {
                        $item.animate({width: bigWidth}, {duration: sizeSpeed,easing: sizeEasing,queue: false,complete: next});
                    });
                    $item.queue(function() {
                        $(".open", item).stop(1, 1).animate({height: getColumnTargetHeight(item)}, sizeSpeed, sizeEasing, function() {
                            $item.dequeue();
                        });
                    });
                    $item.queue(function() {
                        otherCols.find(".closed").stop(1, 1).animate({opacity: 1}, fadeSpeed, fadeEasing);
                        $(".open > .open-content", item).stop(1, 1).animate({opacity: 1}, fadeSpeed, fadeEasing);
                    });
                    return false;
                });
            });
            init();
        });
    })();
    jQuery.WPV.initPortfolioGallery = function(context) {
        var SIZE_FIXED;
        function fixHeight(viewer) {
            if (viewer.css("position") == "static") {
                viewer.css("position", "relative");
            }
            viewer.css("height", "auto").css({overflow: "hidden",height: viewer.height()});
        }
        $("article.portfolio", context || document).each(function(i, o) {
            var viewer = $("> .row > .portfolio_image_wrapper", this), thumbs = $("> .row > .portfolio_details a.portfolio-small", this);
            if (!thumbs.length)
                return;
            thumbs.removeClass("lightbox").unbind("click").bind("click.portfolioGallery", function(e) {
                if (!SIZE_FIXED) {
                    fixHeight(viewer);
                    SIZE_FIXED = 1;
                }
                var oldView = $("> a.portfolio_image, > img", viewer).css({zIndex: 1}), newView = $('<img />').css({position: "absolute",zIndex: 3,left: 0,top: 0,opacity: 0}).attr({alt: $("> img", this).attr("alt")}).appendTo(viewer);
                newView.bind("load", function(e) {
                    viewer.css("height", viewer.height()).animate({"height": "+=" + (newView.height() - oldView.height())}, 400);
                    oldView.animate({opacity: 0}, 400);
                    newView.animate({opacity: 1}, 400, function() {
                        newView.css({zIndex: 1,position: "relative"});
                        oldView.unbind().remove();
                        viewer.css("height", "auto");
                    });
                }).attr("src", this.href);
                return false;
            });
        });
    };
    jQuery.WPV.initPortfolioGallery();
    if ($.browser.msie && $.browser.version < 9) {
        $('p:empty').hide();
        $('*:last-child').addClass('last last-child');
        var logo = $(".main-header .logo");
        if (logo.length) {
            var logoImage = logo.find("> img");
            if (logoImage.length === 1) {
                logo.width(logoImage[0].offsetWidth);
            }
        }
    }
    $(window).bind("load", function() {
        setTimeout(function() {
            $(window).trigger("resize");
        }, 1);
    });
    $('#feedback.slideout').click(function(e) {
        var wrap = $(this).parent().toggleClass("expanded");
        e.preventDefault();
    });
    (function() {
        function fixSidebars(container) {
            var cols = $(".page-wrapper", container);
            if ($("> .ajax-result", cols).length) {
                cols = cols.find("> .ajax-result");
            }
            cols = cols.find("> div, > article, > aside").css("minHeight", 0);
            if (MEDIA.layout["layout-below-medium"] || cols.length < 2) {
                return;
            }
            var h = 0;
            cols.each(function(i, o) {
                h = Math.max(h, $(o).outerHeight());
            }).each(function(i, o) {
                var $o = $(o);
                $o.css("minHeight", h - ($o.outerHeight() - $o.height()));
            });
        }
        $.rawContentHandler(function() {
            fixSidebars(this);
        });
        J_WIN.bind("load resize", function() {
            fixSidebars(document);
        });
    })();
    (function() {
        function fix(context) {
            var sidebar = $(".page-wrapper > aside.right, .page-wrapper > .ajax-result > aside.right", context);
            if (sidebar.length) {
                var btns = $("header.page-header").find("a[rel=prev], .all-items, a[rel=next]").css("minWidth", MEDIA.layout["layout-below-medium"] ? 50 : 0), len = btns.length;
                if (len && !MEDIA.layout["layout-below-medium"]) {
                    var widthTotal = sidebar.width(), widthSoFar = 0, widthPerBtn = Math.floor(widthTotal / len);
                    btns.each(function(i, btn) {
                        if (i === len - 1) {
                            $(btn).css("minWidth", widthTotal - widthSoFar);
                        } 
                        else {
                            $(btn).css("minWidth", widthPerBtn - 1);
                            widthSoFar += widthPerBtn;
                        }
                    });
                }
            }
        }
        $.rawContentHandler(function() {
            fix(this);
        });
        J_WIN.bind("load resize", function() {
            fix(document);
        });
    })();
    $.rawContentHandler(function() {
        $(".row > .nomargin:first-child").each(function() {
            var row = $(this).parent();
            if (row.find("img.jail.loading").length) {
                row.bind("jailComplete", function() {
                    if (row.find("img.jail.loading").length === 0) {
                        row.find(".services.has-image.smallimage .shrinking-outer").css("minHeight", 0).each(function() {
                            h = Math.max(h, $(this).height());
                        }).css("minHeight", h);
                        row.unbind("jailComplete");
                    }
                });
            }
        });
        $(".shrinking-outer").each(function() {
            var a = $(this).find("a");
            if (a.length) {
                $(this).css("cursor", "pointer").click(function() {
                    a[0].click();
                });
            }
        });
    });
    $.rawContentHandler(function() {
        $('.vamtam-slider').touchwipe({preventDefaultEvents: false,canUseEvent: function(e) {
                return $(e.target).is(".slide, .slide *");
            },wipeLeft: function(e) {
                e.preventDefault();
                $(this).vamtamSlider("pos", "next");
            },wipeRight: function(e) {
                e.preventDefault();
                $(this).vamtamSlider("pos", "prev");
        }});
        $(".fast-slider").touchwipe({canUseEvent: function(e) {
                return $(e.target).is(".fast-slider");
            },wipeLeft: function() {
                $(this).data("fastSlider") && $(this).data("fastSlider").prev();
            },wipeRight: function() {
                $(this).data("fastSlider") && $(this).data("fastSlider").next();
            },wipeDown: function() {
                $(this).data("fastSlider") && $(this).data("fastSlider").goToPrevGalleryItem();
            },wipeUp: function() {
                $(this).data("fastSlider") && $(this).data("fastSlider").goToNextGalleryItem();
        }});
    });
    $.rawContentHandler(function(node) {
        var bgSize = $.getCssPropertyName("backgroundSize");
        $(".loop-wrapper.news .thumbnail, .posts_list .thumbnail", node).each(function(i, thumb) {
            var img = $("img[src]", this);
            if (img.length === 1) {
                if (bgSize) {
                    $(thumb).css({background: "transparent url('" + img.attr("src") + "') center center no-repeat scroll",backgroundSize: "cover"}).addClass("generic-thumbnail");
                } 
                else {
                    $(thumb).thumbnail({url: img.attr("src"),autoConfig: $.browser.msie});
                }
                img.remove();
            }
        });
    });
    $("body").on("mouseenter", ".linkarea[data-hoverclass]", function() {
        $(this).addClass(this.getAttribute("data-hoverclass"));
    }).on("mouseeleave", ".linkarea[data-hoverclass]", function() {
        $(this).removeClass(this.getAttribute("data-hoverclass"));
    }).on("mousedown", ".linkarea[data-activeclass]", function() {
        $(this).addClass(this.getAttribute("data-activeclass"));
    }).on("mouseup", ".linkarea[data-activeclass]", function() {
        $(this).removeClass(this.getAttribute("data-activeclass"));
    }).on("click", ".linkarea[data-href]", function(e) {
        if (e.isDefaultPrevented()) {
            return false;
        }
        var href = this.getAttribute("data-href");
        if (href) {
            e.preventDefault();
            e.stopImmediatePropagation();
            try {
                var target = String(this.getAttribute("data-target") || "self").replace(/^_/, "");
                if (target == "blank" || target == "new") {
                    window.open(href);
                } 
                else {
                    window[target].location = href;
                }
            } catch (ex) {
            }
        }
    });
    $("body").on("click", ".print-btn", function() {
        window.print();
    });
    $.rawContentHandler(function() {
        var likeHTML = $("#like-btns-template").html();
        var btn = $(".page-header .share-btn");
        if (likeHTML) {
            if (!btn.length) {
                btn = $('<span class="share-btn">\
                <div class="like-menu-container"></div>\
                </span>').insertBefore(".page-header .spacer");
            }
            btn.unbind();
            btn.bind("mouseenter", function() {
                var menu = $("#like-menu");
                if (!menu.length) {
                    menu = $('<div id="like-menu"/>').appendTo("body");
                    menu.hover(function() {
                        $("body").addClass("show-like-menu");
                    }, function() {
                        $("body").removeClass("show-like-menu");
                    });
                }
                var container = btn.find(".like-menu-container");
                menu.empty();
                menu.css({top: container.offset().top + container.outerHeight(),right: $("body").width() - (container.offset().left + container.outerWidth())});
                $("body").addClass("show-like-menu");
                menu.html(likeHTML.replace(/^<\!--/, "").replace(/-->$/, "")).prepend('<div class="like-menu-cover"/>');
            });
            btn.bind("mouseleave", function() {
                $("body").removeClass("show-like-menu");
            });
        } 
        else
            btn.remove();
    });
    (function() {
        function stripShareButtons(html) {
            var shareStart = "<!-- Starts share-btns (do not remove this comment) -->";
            var shareEnd = "<!-- Ends share-btns (do not remove this comment) -->";
            var start = html.indexOf(shareStart);
            var end = html.indexOf(shareEnd);
            if (start > -1 && end > -1) {
                html = html.substring(0, start) + html.substr(end + shareEnd.length);
            }
            return html;
        }
        function parseReducedResponce(text, callback) {
            var data = {};
            $.each(text.split("-----VAMTAM-----SPLIT-----"), function(i, token) {
                var index = token.indexOf("|");
                if (index > -1) {
                    data[token.substr(0, index)] = token.substr(index + 1);
                }
            });
            var awaited = 0, ready = 0;
            function commonCallback() {
                if (++ready >= awaited)
                    callback(data);
            }
            $.each(["jquery.jplayer.min.js", "jquery.sequence.js"], function(i, script) {
                if (data.scripts.indexOf(script) > -1) {
                    var src = data.scripts.match(new RegExp("<script .*?src=['\"](.*?" + script + ".*?)['\"]", "i"));
                    if (src && src[1]) {
                        awaited++;
                        jQuery.getScript(src[1], commonCallback);
                    }
                }
            });
            if (awaited < 1) {
                callback(data);
            }
            console.log(data)
            return data;
        }
        $("body").on("click.pagination", ".load-more", function(e) {
            if ($(this).is(":animated")) {
                return false;
            }
            var $currentLink = $(this);
            var $currentList = $currentLink.prev();
            var containerSelector = $currentList.is("section.portfolios > ul") ? "section.portfolios > ul" : $currentList.is(".loop-wrapper") ? ".loop-wrapper:first" : null;
            if (containerSelector) {
                $(this).addClass("loading").find("> *").animate({opacity: 0});
                $.ajax({url: $("a.lm-btn", this).attr("href"),dataType: "text",success: function(html) {
                        html = stripShareButtons(html);
                        var article = $('<div/>').html(html.replace(/[\s\S]*?<article\b[^>]*>([\s\S]*)<\/article>[\s\S]*/i, "$1").replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, '<span class="script" style="display:none">$1</span>'));
                        var newContainer = $(containerSelector, article);
                        if (newContainer.length) {
                            var startHeight = $currentList.height();
                            var newItems = newContainer.children().css("opacity", 0);
                            $currentList.append(newItems);
                            $("span.script", $currentList).each(function(i, o) {
                                $.globalEval($(o).text());
                            }).remove();
                            $currentList.trigger("rawContent", newItems.get());
                            var endHeight = $currentList.height();
                            $currentList.height(endHeight);
                            $currentList.css("height", "auto").children().animate({opacity: 1}, 1000);
                            jQuery.WPV.initHoverFX($currentList);
                            var newPager = $(".load-more", article);
                            if (newPager.length) {
                                $currentLink.html(newPager.html()).removeClass("loading").find("> *").animate({opacity: 1}, 600, "linear");
                            } 
                            else {
                                $currentLink.slideUp().remove();
                            }
                            $(window).trigger("resize").trigger("scroll");
                            article = newContainer = startHeight = endHeight = newPager = null;
                        }
                }});
            }
            return false;
        });
        $("body").on("click.pagination", ".page-header a[rel=next], .page-header a[rel=prev]", function(e) {
            e.preventDefault();
            e.stopPropagation();
            var thisContainer = $("#main").find(".page-wrapper:first");
            if (thisContainer.css("position") == "static") {
                thisContainer.css("position", "relative");
            }
            $(this).addClass("loading").css({color: "transparent !important"});
            if ($.fn.jPlayer) {
                $(".jp-jplayer").jPlayer("destroy");
            }
            var newUrl = $(this).attr("href");
            $.ajax({url: newUrl,data: {reduced: 1},dataType: "text",success: function(html) {
                    parseReducedResponce(html, function(data) {
                        if (data.title) {
                            document.title = data.title;
                            if (window.history.pushState) {
                                history.pushState({location: newUrl}, data.title, newUrl);
                            }
                        }
                        if (data.ptitle) {
                            $("header.page-header").replaceWith(data.ptitle);
                        }
                        if (data.content) {
                            var _html = data.content.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(all, code) {
                                return '<span class="script" style="display:none">' 
                                + encodeURIComponent(code) 
                                + '</span>';
                            });
                            _html = stripShareButtons(_html);
                            _html = $.trim(_html);
                            var oldChildren = thisContainer.children();
                            var page = $('<div class="ajax-result"/>').css({height: "auto",opacity: 0}).appendTo(thisContainer).html(_html);
                            $(".page-wrapper:first", page).removeClass("page-wrapper");
                            $(".load-more, .widget.wpv_flickr", page).remove();
                            $("span.script", page).each(function(i, o) {
                                $.globalEval(decodeURIComponent($(o).text()));
                            }).remove();
                            page.trigger("rawContent");
                            var _done = 0;
                            function commonCallback() {
                                if (++_done == 2) {
                                    jQuery.WPV.initPortfolioGallery(page);
                                    $('#commentform').validator();
                                    $(window).trigger("resize").trigger("scroll");
                                }
                            }
                            oldChildren.each(function(i) {
                                $(this).animate({opacity: 0}, 800, "linear", function() {
                                    $(this).find("*").unbind().removeData().end().empty().remove();
                                    if (i >= oldChildren.length - 1)
                                        commonCallback();
                                });
                            });
                            page.animate({opacity: 1}, 1000, "linear", commonCallback);
                        }
                    });
            }});
        });
    })();
    J_WIN.triggerHandler('resize.sizeClass');
})(jQuery);
(function($) {
    var DURATION = 720;
    var LTIE9 = $.browser.msie && $.browser.version < 9;
    $.fn.scaleY = function(val, toBottom) {
        if (LTIE9) {
            $.fn.scaleY = function(val, toBottom) {
                return this.each(function(i, el) {
                    if (el.filters.length) {
                        el.filters.item(0).M22 = val;
                        el.filters.item(0).Dy = toBottom ? el.offsetHeight * (1 - val) : 0;
                    }
                });
            };
            return this.scaleY(val, toBottom);
        }
        if ($.WPV.Constants.vendor.transform) {
            this.css($.WPV.Constants.vendor.transform, "scaleY(" + val + ")");
        }
        return this;
    };
    function Counter(elem) 
    {
        this.elem = elem;
        this._init();
    }
    Counter.getInstance = function(elem) 
    {
        var inst = $(elem).data("Counter");
        if (!inst) {
            inst = new Counter(elem);
            $(elem).data("Counter", inst);
        }
        return inst;
    };
    Counter.prototype._init = function() 
    {
        var value = parseInt(this.elem.innerHTML, 10);
        if (isNaN(value)) {
            value = 0;
        }
        $(this.elem).empty();
        this.set(value);
    };
    Counter.prototype._addCounter = function() 
    {
        $o = $('<div class="counter"/>').appendTo(this.elem);
        $o.html("0").css({height: $o.height(),width: $o.width() + 8}).html('<div class="up a1"/><div class="down a1"/>\
        <div class="up a2"/><div class="down a2"/>\
        <div class="counter-cover" />');
        return $o;
    };
    Counter.prototype.set = function(digit, noAnimation) 
    {
        var digitString = $.trim(String(digit));
        var digitLength = digitString.length;
        var counters = $("> .counter", this.elem);
        var countersLength = counters.length;
        var _self = this;
        if (digitLength < countersLength) {
            counters.filter(function(i, item) {
                return i >= digitLength;
            }).remove();
        } 
        else if (digitLength > countersLength) {
            for (var i = countersLength; i < digitLength; i++) {
                this._addCounter();
            }
        }
        $("> .counter", this.elem).each(function(i, counter) {
            var oldValue = counter.getAttribute("data-value");
            if (oldValue == digitString[i]) {
                return true;
            }
            //$(counter).originalStop(1, 1);
            var $div2 = $(".up.a1", counter).css({zIndex: -1}).scaleY(1, true);
            var $div1 = $(".up.a2", counter).css({zIndex: -2,top: 0}).text(digitString[i]).scaleY(1, true);
            var $div3 = $(".down.a2", counter).css({zIndex: -3,top: "50%"}).text(digitString[i]).scaleY(0);
            var $div4 = $(".down.a1", counter).css("zIndex", -4).scaleY(1);
            if (noAnimation) {
                $div2.scaleY(0, true).css("zIndex", -2).attr("class", "up a2");
                $div1.css("zIndex", -1).attr("class", "up a1");
                $div3.scaleY(1).css("zIndex", -3).attr("class", "down a1");
                $div4.css("zIndex", -4).attr("class", "down a2");
                counter.setAttribute("data-value", digitString[i]);
                return;
            }
            if (!$.WPV.Constants.vendor.transform || !$.WPV.Constants.vendor.transition) {
                $(counter).css("dummy", 0).originalAnimate({dummy: 1}, {duration: DURATION / 2,easing: "easeInCirc",step: function(cur, fx) {
                        if (fx.prop == "dummy") {
                            $div2.scaleY(1 - 1 * fx.pos, true);
                        }
                    },complete: function() {
                        $div2.css("zIndex", -2).attr("class", "up a2");
                        $div1.css("zIndex", -1).attr("class", "up a1");
                }}).originalAnimate({dummy: 0}, {duration: DURATION / 2,easing: "easeOutCirc",step: function(cur, fx) {
                        if (fx.prop == "dummy") {
                            $div3.scaleY(fx.pos);
                        }
                    },complete: function() {
                        $div3.css("zIndex", -3).attr("class", "down a1");
                        $div4.css("zIndex", -4).attr("class", "down a2");
                        counter.setAttribute("data-value", digitString[i]);
                }});
            } 
            else {
                var div2to = {};
                div2to[$.WPV.Constants.vendor.transform] = "scaleY(0)";
                var div3to = {};
                div3to[$.WPV.Constants.vendor.transform] = "scaleY(1)";
                $div2.setTransition(div2to, DURATION / 2, "easeInCirc", 0, function() {
                    $div2.css("zIndex", -2).attr("class", "up a2");
                    $div1.css("zIndex", -1).attr("class", "up a1");
                    $div3.setTransition(div3to, DURATION / 2, "easeOutCirc", 0, function() {
                        $div3.css("zIndex", -3).attr("class", "down a1");
                        $div4.css("zIndex", -4).attr("class", "down a2");
                        counter.setAttribute("data-value", digitString[i]);
                    });
                });
            }
        });
    };
    jQuery.fn.counter = function(val, noAnimation) {
        var val = Number(val) || 0;
        return this.each(function(i, o) {
            Counter.getInstance(o).set(val, noAnimation);
        });
    };
})(jQuery);
(function($) {
    var TPL_BTN_LEFT = '<div class="scrollbar-btn-left"><div /></div>';
    var TPL_BTN_RIGHT = '<div class="scrollbar-btn-right"><div /></div>';
    var TPL_BTN_TOP = '<div class="scrollbar-btn-top"><div /></div>';
    var TPL_BTN_BOTTOM = '<div class="scrollbar-btn-bottom"><div /></div>';
    var TPL_CENTER = '<div class="scrollbar-scrollarea">' 
    + '<div class="scrollbar-btn-main">' 
    + '<div />' 
    + '</div>' 
    + '</div>';
    function getColCount($elem) {
        if (MEDIA.layout["layout-below-medium"])
            return 1;
        if ($elem.is(".portfolio_four_columns"))
            return 4;
        if ($elem.is(".portfolio_three_columns"))
            return 3;
        if ($elem.is(".portfolio_two_columns"))
            return 2;
        return 1;
    }
    function getPortfolioColumnWidth($ul) {
        switch (getColCount($ul)) {
            case 2:
                return 0.49;
            case 3:
                return 0.32;
            case 4:
                return 0.235;
        }
        return 1;
    }
    function initLayout($ul) {
        var lis = $ul.find(" > li").removeClass("fit"), cCount = getColCount($ul);
        if (cCount === 1) {
            $ul.css({width: "100%"});
            lis.css({width: "100%","float": "none",display: "block",marginRight: 0});
            return;
        }
    }
    function createScrollBarX(options) {
        var html = ['<div class="scrollbar-horizontal">'];
        switch (options.arrowButtons) {
            case "left":
                html.push(TPL_BTN_LEFT, TPL_BTN_RIGHT, TPL_CENTER);
                break;
            case "right":
                html.push(TPL_CENTER, TPL_BTN_LEFT, TPL_BTN_RIGHT);
                break;
            case "none":
                html.push(TPL_CENTER);
                break;
            default:
                html.push(TPL_BTN_LEFT, TPL_CENTER, TPL_BTN_RIGHT);
                break;
        }
        html.push('</div>');
        return $(html.join(""));
    }
    function createScrollBarY(options) {
        var html = ['<div class="scrollbar-vertical">'];
        switch (options.arrowButtons) {
            case "top":
                html.push(TPL_BTN_TOP, TPL_BTN_BOTTOM, TPL_CENTER);
                break;
            case "bottom":
                html.push(TPL_CENTER, TPL_BTN_TOP, TPL_BTN_BOTTOM);
                break;
            case "none":
                html.push(TPL_CENTER);
                break;
            default:
                html.push(TPL_BTN_TOP, TPL_CENTER, TPL_BTN_BOTTOM);
                break;
        }
        html.push('</div>');
        return $(html.join(""));
    }
    function sync(elem) {
        var scrollBars = $(elem).data("scrollBars");
        if (scrollBars) {
            if (scrollBars.horizontal) {
                var scrollWidth = elem.scrollWidth, scrollbarWidth = 100 * (elem.clientWidth / scrollWidth), scrollbarLeft = 100 * (elem.scrollLeft / scrollWidth);
                scrollBars.horizontal.find(".scrollbar-btn-main > div").css({width: scrollbarWidth + "%",left: scrollbarLeft + "%"}).end().toggleClass("disabled", scrollbarWidth >= 100);
                ;
            }
            if (scrollBars.vertical) {
                var scrollHeight = elem.scrollHeight, scrollbarHeight = 100 * (elem.clientHeight / scrollHeight), scrollbarTop = 100 * (elem.scrollTop / scrollHeight);
                scrollBars.vertical.find(".scrollbar-btn-main > div").css({height: scrollbarHeight + "%",left: scrollbarTop + "%"}).end().toggleClass("disabled", scrollbarHeight >= 100);
            }
        }
    }
    function attachListeners(elem, scrollbarX, scrollbarY) {
        if (scrollbarX) {
            var EVENT_ROOT = $.browser.msie && $.browser.version < 9 ? document : window;
            scrollbarX.find(".scrollbar-scrollarea").bind("mousedown", function(e) {
                var $btnWrap = $(this).find(".scrollbar-btn-main"), $btn = $btnWrap.find(" > div").addClass("active"), btnWidth = $btn.width(), width = $btnWrap.width(), delta = $btn.offset().left - e.pageX;
                function set(x) {
                    var deltaX = x - $btnWrap.offset().left;
                    var left = width * (deltaX / width);
                    left += delta;
                    left = Math.max(left, 0);
                    left = Math.min(left, width - btnWidth);
                    elem.scrollLeft = Math.ceil(left * (elem.scrollWidth / width));
                    $(elem).trigger("scroll");
                }
                if (e.target === $btn[0]) {
                    set(e.pageX);
                } 
                else {
                    var l = elem.scrollWidth - elem.clientWidth;
                    l *= (e.pageX - $btnWrap.offset().left) / $btnWrap.width();
                    $(elem).originalStop(1, 0).originalAnimate({scrollLeft: l}, {duration: 300,easing: "easeInOutCirc",step: function() {
                            $(elem).trigger("scroll");
                        },complete: function() {
                            delta = $btn.offset().left - e.pageX;
                    }});
                }
                $(EVENT_ROOT).bind("mousemove.sliderdrag", function(e) {
                    set(e.pageX);
                    return false;
                });
                $(EVENT_ROOT).bind("mouseup.sliderdrag", function(e) {
                    $(this).unbind(".sliderdrag");
                    $btn.removeClass("active");
                });
                return false;
            });
            var delay, timer;
            scrollbarX.find(".scrollbar-btn-left, .scrollbar-btn-right").bind("mousedown", function(e) {
                var step = (function(_step) {
                    return function(single) {
                        if (single) {
                            $(elem).originalStop(1, 0).originalAnimate({scrollLeft: elem.scrollLeft + _step * 100}, {duration: 200,easing: "easeInOutQuad",step: function() {
                                    $(elem).trigger("scroll");
                            }});
                        } 
                        else {
                            elem.scrollLeft += _step * 10;
                            $(elem).trigger("scroll");
                            timer = setTimeout(step, 0);
                        }
                    };
                })($(this).is(".scrollbar-btn-left") ? -1 : 1);
                if (delay)
                    clearTimeout(delay);
                if (timer)
                    clearTimeout(timer);
                step(true);
                delay = setTimeout(step, 200);
            }).bind("mouseleave mouseup", function(e) {
                if (delay)
                    clearTimeout(delay);
                if (timer)
                    clearTimeout(timer);
            });
        }
    }
    function getScrollBarX(elem, options) {
        var o = $(elem).data("scrollBars");
        if (!o) {
            o = {};
            $(elem).data("scrollBars", o);
        }
        if (!o.horizontal) {
            o.horizontal = $(elem).next(":first");
            if (!o.horizontal.length || !o.horizontal.is(".scrollbar-horizontal")) 
                {
                o.horizontal = createScrollBarX(options);
            }
            attachListeners(elem, o.horizontal);
        }
    }
    $.fn.scrollable = function(options) {
        var hasNativeTouchScroll = !!$.getCssPropertyName("-webkit-overflow-scrolling");
        return this.each(function(i, o) {
            if (!hasNativeTouchScroll)
                getScrollBarX(o, options);
            $(window).bind("resize scroll switchlayout", function(e) {
                if (e.type == "switchlayout") {
                    initLayout($("> ul", o));
                }
                (!hasNativeTouchScroll && sync(o));
            });
            initLayout($("> ul", o));
            (!hasNativeTouchScroll && sync(o));
            $(o).addClass("loaded");
        });
    };
})(jQuery);
var iddd;
$(document).ready(function(){
    if($.browser.msie)
        {
        jQuery('#mobile_footer_menu').hide();
    }
    if (MEDIA.layout["layout-max"]) {
        $('body').removeClass('show-menu');
        $('#menus').unsetTransition().css({height: "auto",height: (jQuery('#menus').parent().height()),overflow: "visible"});
    } 
    else {
        if (!$('body').is('.show-menu')) {
            $('body').addClass('show-menu');
            $('#menus').css({overflow: "hidden",height: 0});

        }
    }

    jQuery('#mobile_footer_menu').html(jQuery('#main_menu').html())
    jQuery('#mobile_footer_menu .menu_child').fadeOut();
    $('#mobile_footer_menu .have_child').click(function() {
        if(jQuery(this).children().eq(1).css('display') == 'none')
            {
            $('#mobile_footer_menu .show_child ul').fadeOut(700);
            $('#mobile_footer_menu .show_child').removeClass("show_child");
            jQuery(this).addClass("show_child")
            jQuery(this).children().eq(1).fadeIn(700);          
        }
        else
            {
            jQuery(this).removeClass("show_child");
            jQuery(this).children().eq(1).fadeOut(700);
        }  
    });

});



